# 导入泛型库
from typing import TypeVar, Generic

# 定义类型变量
T = TypeVar("ANY")


class Stack(Generic[T]):

    def __init__(self):

        self.items: list[T] = []

    def push(self, item: T) -> None:
        self.items.append(item)

    def pop(self) -> T:
        return self.items.pop()


stack = Stack[int]()  # 定义队列只能保存int类型

for i in range(10):
    stack.push(i)

stack_str_list = Stack[str]()

for i in range(10):
    stack_str_list.push(str(i) + "-STR")

print("item===", stack_str_list.items)
